package com.huike.game.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.huike.game.R;

import java.util.ArrayList;

public class GvAdapter extends BaseAdapter {
    private ArrayList<String> list;
    private Context context;

    public GvAdapter(ArrayList<String> list,Context context){
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        Log.e("TAG", list.get(i));
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        GvHoder hoder = null;
        if(view == null){
            hoder = new GvHoder();
            view = View.inflate(context, R.layout.gv_item,null);
            hoder.tv = view.findViewById(R.id.gv_tv);
            view.setTag(hoder);
        }else{
            hoder = (GvHoder) view.getTag();
        }

        String result = list.get(i);
        hoder.tv.setText(result);

        return view;
    }

    class GvHoder{
        public TextView tv;
    }

}

